package cn.wxxyhw.dao;

import cn.wxxyhw.entity.Employee;
import org.springframework.stereotype.Controller;

import java.util.Collection;
import java.util.HashMap;

@Controller
public class EmployeeDao {
    private static HashMap<String, Employee> employees= new HashMap<>();
    static {
        employees.put("1",new Employee(1,"AAAA","aaaa@aaaa","男"));
        employees.put("2",new Employee(2,"BBBB","bbbb@aaaa","女"));
        employees.put("3",new Employee(3,"CCCC","cccc@aaaa","女"));
        employees.put("4",new Employee(4,"DDDD","dddd@aaaa","男"));
        employees.put("5",new Employee(5,"EEEE","eeee@aaaa","女"));
        employees.put("6",new Employee(6,"FFFF","ffff@aaaa","男"));
    }

    public Collection<Employee> getEmployees(){
        return employees.values();
    }

    public Employee getEmployeeById(String id){
        Employee employee = employees.get(id);
        return employee;
    }
    public void save(Employee employee){
        employees.put(String.valueOf(employee.getId()),employee);
    }

    public void delete(String id){
        employees.remove(id);
    }
}
